class_name FnPool

static func base_tween(ease:=Tween.EASE_IN_OUT, trans:=Tween.TRANS_CUBIC) -> Tween:
	var tween = Engine.get_main_loop().root.create_tween()
	tween.set_ease(ease).set_trans(trans)
	return tween
	
static func _pivot_offset(node:Node, offset :=Vector2(0.5, 0.5)):
	node.pivot_offset = Vector2(node.size.x* offset.x, node.size.y* offset.y)

static func _copy_to_use(node:Node, args:=[], kwargs:={}):
	var tween = base_tween()
	
	
static func scale(node:Node, args:=[], kwargs:={}):
	_pivot_offset(node)
	base_tween().tween_property(node, "scale", Vector2.ONE*args[0], args[1])

static func move(node:Node, args:=[], kwargs:={}):
	_pivot_offset(node)
	base_tween().tween_property(node, "position", args[0], args[1]).as_relative()

static func visible(node:Node, args:=[], kwargs:={}):
	_pivot_offset(node)
	var tween = node.create_tween()
	base_tween().tween_property(node, "modulate:a", args[0], args[1])

static func mouse_in(node:Node, args:=[], kwargs:={}):
	_pivot_offset(node)
	var tween = base_tween()
	tween.tween_property(node, "scale", Vector2.ONE*args[1], args[0])
static func mouse_out(node:Node, args:=[], kwargs:={}):
	_pivot_offset(node)
	var tween = base_tween()
	tween.tween_property(node, "scale", Vector2.ONE*args[2], args[0])
static func mouse_in_out(node:Node, args:=[], kwargs:={}):
	if not kwargs.has("is_entered"):
		return
	_pivot_offset(node)
	var tween = base_tween()
	if kwargs.get("is_entered"):
		tween.tween_property(node, "scale", Vector2.ONE*args[1], args[0])
	else:
		tween.tween_property(node, "scale", Vector2.ONE*args[2], args[0])
static func mouse_pressed(node:Node, args:=[], kwargs:={}):
	_pivot_offset(node)
	var tween = base_tween()
	tween.tween_property(node, "modulate:a", args[1], args[0])
static func mouse_released(node:Node, args:=[], kwargs:={}):
	_pivot_offset(node)
	var tween = base_tween()
	tween.tween_property(node, "modulate:a", args[2], args[0])
static func mouse_pressed_released(node:Node, args:=[], kwargs:={}):
	if not kwargs.has("is_pressed"):
		return
	_pivot_offset(node)
	var tween = base_tween()
	if not kwargs.get("is_pressed"):
		tween.tween_property(node, "modulate:a", args[1], args[0])
	else:
		tween.tween_property(node, "modulate:a", args[2], args[0])
